﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using System.Collections;

namespace B2B.Models
{
    public class SP_QuoteCreate
    {
        string file;

        public string File
        {
            get { return file; }
            set { file = value; }
        }
        int maSP;

        public int MaSP
        {
            get { return maSP; }
            set { maSP = value; }
        }
        string emailNguoiGui;

        public string EmailNguoiGui
        {
            get { return emailNguoiGui; }
            set { emailNguoiGui = value; }
        }
        string emailNguoiNhan;

        public string EmailNguoiNhan
        {
            get { return emailNguoiNhan; }
            set { emailNguoiNhan = value; }
        }
        string link;

        public string Link
        {
            get { return link; }
            set { link = value; }
        }

        private int maSPM;



        public int MaSPM
        {
            get { return maSPM; }
            set { maSPM = value; }
        }

        public int ThemBaoGia(SP_QuoteCreate sp_QuoteCreate, int loai)
        {
            SqlConnection conn = KetNoi.Connection();
            SqlCommand cmd = new SqlCommand("SP_THEMBAOGIA", conn);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@FILE", sp_QuoteCreate.File);
            if (loai == 1)
            {
                cmd.Parameters.AddWithValue("@MASP", sp_QuoteCreate.MaSP);
                cmd.Parameters.AddWithValue("@LINK", sp_QuoteCreate.Link);
            }
            else
            {
                cmd.Parameters.AddWithValue("@LINK", DBNull.Value);
                cmd.Parameters.AddWithValue("@MASP", DBNull.Value);
            }
            cmd.Parameters.AddWithValue("@EMAILNGUOIGUI", sp_QuoteCreate.emailNguoiGui);
            cmd.Parameters.AddWithValue("@EMAILNGUOINHAN", sp_QuoteCreate.EmailNguoiNhan);
            
            if (loai == 1)
                cmd.Parameters.AddWithValue("@MASPM", DBNull.Value);
            else
                cmd.Parameters.AddWithValue("@MASPM", sp_QuoteCreate.MaSPM);
            conn.Open();
            int kq = cmd.ExecuteNonQuery();
            conn.Close();
            return kq;
        }
    }
}